<template>
  <div class="app-container">
    <el-form size="small" :inline="true" v-show="showSearch">
      <el-form-item label="查询时间" prop="dateRange">
        <el-date-picker
          v-model="formData.dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          unlink-panels
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="查询间隔：" prop="querySpace">
        <el-select v-model="formData.querySpace" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出
        </el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="TjlResultList">
      <el-table-column align="center" label="一期原水流量" prop="yqJsll" width="120"/>
      <el-table-column align="center" label="二期原水流量" prop="fit102" width="120"/>
      <el-table-column align="center" label="盖竹浊度" prop="mit101T" width="120"/>
      <el-table-column align="center" label="盖竹PH" prop="ait101Ph" width="120"/>
      <el-table-column align="center" label="盖竹温度" prop="ait101T" width="120"/>
      <el-table-column align="center" label="高楼浊度" prop="jnyszd" width="120"/>
      <el-table-column align="center" label="高楼PH" prop="jnysph" width="120"/>
      <el-table-column align="center" label="一期加药投加量" prop="yqTjlShowAvg" :show-overflow-tooltip="true" width="150"/>
      <el-table-column align="center" label="二期加药投加量" prop="eqTjlShowAvg" :show-overflow-tooltip="true" width="150"/>
      <el-table-column align="center" label="查询时间" prop="dateTime" :show-overflow-tooltip="true" width="180"/>
    </el-table>
  </div>
</template>

<script>
import {listTjlResult} from "@/api/system/tjlResult";

export default {
  name: "Role",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      options: [{
        value: '24:00:00',
        label: '二十四小时'
      }, {
        value: '12:00:00',
        label: '十二小时'
      }, {
        value: '04:00:00',
        label: '四小时'
      }, {
        value: '01:00:00',
        label: '一小时'
      }, {
        value: '00:30:00',
        label: '三十分钟'
      }, {
        value: '00:15:00',
        label: '十五分钟'
      }, {
        value: '00:10:00',
        label: '十分钟'
      }, {
        value: '00:05:00',
        label: '五分钟'
      }, {
        value: '00:01:00',
        label: '一分钟'
      }],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      TjlResultList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      formData: {
        dateRange: [],
        querySpace: null
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      if (this.formData.dateRange[0] && !this.formData.querySpace) {
        this.$message.warning('请输入查询间隔！');
        this.loading = false;
        return
      }
      if (this.formData.querySpace && !this.formData.dateRange[0]) {
        this.$message.warning('请输入查询时间！');
        this.loading = false;
        return
      }
      listTjlResult(this.formData).then(response => {
          this.TjlResultList = response.data;
          this.loading = false;
        }
      );
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        roleId: undefined,
        roleName: undefined,
        roleKey: undefined,
        roleSort: 0,
        status: "0",
        menuIds: [],
        deptIds: [],
        menuCheckStrictly: true,
        deptCheckStrictly: true,
        remark: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.formData.dateRange = [];
      this.formData.querySpace = '';
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      if (this.formData.dateRange[0] && !this.formData.querySpace) {
        this.$message.warning('请输入查询间隔！');
        this.loading = false;
        return
      }
      if (this.formData.querySpace && !this.formData.dateRange[0]) {
        this.$message.warning('请输入查询时间！');
        this.loading = false;
        return
      }
      this.download('system/tjlResult/export', {
        ...this.formData
      }, `模糊控制结果_${new Date().getTime()}.xlsx`)
    },
  }
};
</script>
